<?php
require_once 'TemplateGenerator.php';

if (isset($_POST["upload"]))
{
  if (!empty($_FILES['ufile']))
  {
    //check for image submitted
    if ($_FILES['ufile']['error'] > 0)
    {
      // check for error re file
      echo "Error: " . $_FILES["ufile"]["error"] ;
    }
    else
    {
      //move temp file to our server
      //move_uploaded_file($_FILES['my_file']['tmp_name'], $upload_directory . $_FILES['my_file']['name']);
       
      $template_gen = new TemplateGenerator();
      $template_gen->createTemplate($_FILES['ufile']['tmp_name'],$_FILES['ufile']['name']);

      //echo 'Uploaded File.';
    }
  }
}
?>
<html>
<head>
<title>Template Upload</title>
<style type="text/css">
@import "template-dragon_form-style.css";
</style>
<script language="JavaScript" src="jquery.js"></script>
<script language="JavaScript" src="jquery.validation.js"></script>
<script type="text/javascript"> 
    $(document).ready(function() { 
       $("#form1").validate({ 
         rules: { 
      	   ufile: "required"
         } 
       }); 
     }); 
   </script>
</head>
<body>

<form id="form1" action="" method="post" enctype="multipart/form-data">
<input type="file" name="ufile" /><br />
<input type="submit" name="upload" value="Upload" /></form>

</body>
</html>